//
//  LYQFoundBusinessTableViewCell.m
//  ZCProject
//
//  Created by 崔明燃 on 16/11/8.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQFoundBusinessTableViewCell.h"

#define kIconWith 20
#define kIconHeight 15
#define kBottomLabelWith 20
#define kBottomLabelHeight 15

@implementation LYQFoundBusinessTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellAccessoryNone;
        
        [self.contentView addSubview:self.iconImageView];
        [self.contentView addSubview:self.infoTitleLabel];
        
        [self.contentView addSubview:self.lineView1];
        
        [self.contentView addSubview:self.infoContentLabel];
        
        [self.contentView addSubview:self.lineView2];
        
        [self.contentView addSubview:self.eyeIcon];
        [self.contentView addSubview:self.shareIcon];
        [self.contentView addSubview:self.readLabel];
        [self.contentView addSubview:self.shareLabel];
        [self.contentView addSubview:self.sendApplyButton];
        
        [self subViewsLayout];
    }
    
    return self;
}

- (void)subViewsLayout {
    
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(10);
        make.left.equalTo(self.contentView.mas_left).offset(10);
        make.width.equalTo(@80);
        make.height.equalTo(@35);
    }];
    
    [_infoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconImageView.mas_top).offset(0);
        make.left.equalTo(_iconImageView.mas_right).offset(20);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.height.equalTo(@40);
    }];
    
    [_lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_infoTitleLabel.mas_bottom).offset(5);
        make.right.equalTo(self.contentView.mas_right).offset(0);
        make.left.equalTo(self.contentView.mas_left).offset(100);
        make.height.equalTo(@1);
    }];
    
    [_infoContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_lineView1.mas_bottom).offset(10);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
        make.height.equalTo(@50);
    }];
    
    [_lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_infoContentLabel.mas_bottom).offset(5);
        make.left.equalTo(self.contentView.mas_left);
        make.right.equalTo(self.contentView.mas_right);
        make.height.equalTo(@1);
    }];
    
    [_eyeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_lineView2.mas_bottom).offset(5);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.width.equalTo(@(kIconWith));
        make.height.equalTo(@(kIconHeight));
    }];
    
    [_readLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_eyeIcon.mas_top).offset(0);
        make.left.equalTo(_eyeIcon.mas_right).offset(3);
        make.width.equalTo(@(kBottomLabelWith));
        make.height.equalTo(@(kBottomLabelHeight));
    }];
    
    [_shareIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_eyeIcon.mas_top);
        make.left.equalTo(_readLabel.mas_right).offset(3);
        make.width.equalTo(@(kIconWith));
        make.height.equalTo(@(kIconHeight));
    }];
    
    [_shareLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_shareIcon.mas_top).offset(0);
        make.left.equalTo(_shareIcon.mas_right).offset(3);
        make.width.equalTo(@(kBottomLabelWith));
        make.height.equalTo(@(kBottomLabelHeight));
    }];
    
    [_sendApplyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-5);
        make.right.equalTo(self.contentView.mas_right).offset(-10);
        make.width.equalTo(@80);
        make.height.equalTo(@25);
    }];
    
}


#pragma mark - lazy load
- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
        _iconImageView.image = [UIImage imageNamed:@"caigoubg"];
    }
    
    return _iconImageView;
}

- (UILabel *)infoTitleLabel {
    if (!_infoTitleLabel) {
        _infoTitleLabel = [[UILabel alloc] init];
        _infoTitleLabel.text = @"寻找意大利地接社";
        _infoTitleLabel.font = kFont(16);
    }
    
    return _infoTitleLabel;
}

- (UIView *)lineView1 {
    if (!_lineView1) {
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = [UIColor lightGrayColor];
    }
    
    return _lineView1;
}

- (UILabel *)infoContentLabel {
    if (!_infoContentLabel) {
        _infoContentLabel = [[UILabel alloc] init];
        _infoContentLabel.font = kFont(14);
        _infoContentLabel.text = @"10月12日，我们有一个XX人的团去xxx。我们需要资源/服务。希望与您合作，提供相关资料。";
    }
    
    return _infoContentLabel;
}

- (UIView *)lineView2 {
    if (!_lineView2) {
        _lineView2 = [[UIView alloc] init];
        _lineView2.backgroundColor = [UIColor lightGrayColor];
    }
    
    return _lineView2;
}

- (UIImageView *)eyeIcon {
    if (!_eyeIcon) {
        _eyeIcon = [[UIImageView alloc] init];
        _eyeIcon.backgroundColor = [UIColor blueColor];
        _eyeIcon.image = [UIImage imageNamed:@""];
    }
    
    return _eyeIcon;
}

- (UILabel *)readLabel {
    if (!_readLabel) {
        _readLabel = [[UILabel alloc] init];
        _readLabel.font = kFont(14);
        _readLabel.text = @"阅读 200";
    }
    
    return _readLabel;
}

- (UIImageView *)shareIcon {
    if (!_shareIcon) {
        _shareIcon = [[UIImageView alloc] init];
        _shareIcon.backgroundColor = [UIColor blueColor];
        _shareIcon.image = [UIImage imageNamed:@""];
    }
    
    return _shareIcon;
}

- (UILabel *)shareLabel {
    if (!_shareLabel) {
        _shareLabel = [[UILabel alloc] init];
        _shareLabel.font = kFont(14);
        _shareLabel.text = @"分享 2";
    }
    
    return _shareLabel;
}

- (UIButton *)sendApplyButton {
    if (!_sendApplyButton) {
        _sendApplyButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _sendApplyButton.backgroundColor = [UIColor redColor];
    }
    
    return _sendApplyButton;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
